//
//  RelationViewController.m
//  leo
//
//  Created by 常艳 on 15/10/1.
//  Copyright (c) 2015年 mdx. All rights reserved.
//

#import "RelationViewController.h"

@interface RelationViewController ()
@property (nonatomic,retain) NSArray *pickerArray;
@end

@implementation RelationViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    [self.view setFrame:[UIScreen mainScreen].bounds];
    self.picker.delegate=self;
    self.picker.dataSource=self;
    self.pickerArray=[NSArray arrayWithObjects:@"爸爸",@"妈妈",@"爷爷",@"奶奶",@"外公",@"外婆", nil];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
    if(self.view.window==nil)
    {
        self.view=nil;
    }
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/
//返回显示的列数
-(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
    return 1;
}
//返回当前列显示的行数
-(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
    
    return self.pickerArray.count;
    
}

#pragma mark Picker Delegate Methods

//返回当前行的内容,此处是将数组中数值添加到滚动的那个显示栏上
-(NSString*)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
    return [self.pickerArray objectAtIndex:row];
    
}
// 当用户选中UIPickerViewDataSource中指定列和列表项时激发该方法
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
    self.select=[NSString stringWithFormat:@"%@",[self.pickerArray objectAtIndex:row]];
}
- (IBAction)cancle:(id)sender {
    self.motherWindow.hidden=YES;
}
- (IBAction)confirm:(id)sender {
    self.motherLabel.text=self.select;
    self.motherWindow.hidden=YES;
    
}

@end
